package model;

import java.sql.Connection;
import java.sql.PreparedStatement;

import controller.Cliente;
import controller.ContaInvestimento;

/**
*
* @author Juliane
*/
public class ContaInvestimentoDAO {
	//tipo conta corrente = 1 conta investimento = 2
	
	private Connection con;
	private PreparedStatement stmtInserir;
	
	public ContaInvestimentoDAO() throws Exception{
		con = ConFactory.getConnection();
		stmtInserir = con.prepareStatement("INSERT INTO conta(cpf, tipo, depini, saldo, montmin, depmin) VALUES (?,2,?,?,?,?)");
	}
	
	public ContaInvestimentoDAO(Connection con) throws Exception{
		this.con = con;
		stmtInserir = con.prepareStatement("INSERT INTO conta(cpf, tipo, depini, saldo, montmin, depmin) VALUES (?,2,?,?,?,?)");
	}
	
	public void inserirContaInvestimento(ContaInvestimento conta, Cliente cliente) throws Exception{
		stmtInserir.setString(1, cliente.getCpf());
		stmtInserir.setDouble(2, conta.getDepini());
		stmtInserir.setDouble(3, conta.getSaldo());
		stmtInserir.setDouble(4, conta.getMontmin());
		stmtInserir.setDouble(5, conta.getDepmin());
		stmtInserir.executeUpdate();
	}
}
